package cn.i7baozh.boot.learn.thirdproperty;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.config.Profiles;

import java.util.HashMap;
import java.util.Map;

/**
 * 假设这个是从数据库获取配置的服务
 * @author zhangbaoqi532
 * @date 2025/2/24
 */
@Slf4j
public class MyConfigDataService {

    //假设是数据库的地址
    @Setter
    private String url;

    //假设是数据库的用户名
    @Setter
    private String username;

    public void init() {
        System.out.println("我被初始化了！！！！ url: " + url + " username:" + username);
        log.info("我初始化了！！！！ {} , {}", url, username);
    }

    public Map<String, Object> getConfigByTableName(String tableName, Profiles profiles) {
        //select key, value from tableName
        Map<String, Object> configMap = new HashMap<>();
        configMap.put("third.xxConfig", "这个值是从数据库拉取到的");
        return configMap;
    }

}
